﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type="text/javascript" src="jquery-easyui-1.3.1/jquery.easyui.min.js"></script>  
    <script type="text/javascript" src="jquery-easyui-1.3.1/locale/easyui-lang-en.js"></script>
</head>
<body>
    <h3>Catagory:</h3>    
    <div class='input-control select'>
        <select id='selectCategory'>
        </select>
    </div>
    <h3>Amount:</h3>   
    <div class='input-control text'>
        <input type='text' id="idAddIncome" placeholder='Enter Amount' />
        <button class='helper'></button>
    </div>
    <h3>Date:</h3>  
    <div id="dt" class="easyui-calendar" style="width:300px;height:300px;"></div>  
    <h3>Notes:</h3>   
     <div class='input-control textarea'>
        <textarea id="idIncomeNotes">
        </textarea>
    </div> 
    <button id='btnSaveIncome' class='bg-color-darken fg-color-white' style='position:relative; float:right;'>Save</button>
</body>
<script type="text/javascript">
    $(document).ready(function ()
    {
        $('#idWaiting').hide();
        
        var d = new Date();
        var SelectedDate = (d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate());

        var type = GetRecordType(CurrentStep);
        $('#idIncomeNotes').attr('value', '');
        //get all categories of expense
        $.ajax({
            type: "POST",
            url: "General.ashx",
            data: "mode=GetCategories&start=0&end=20&type=" + type,
            async: false,
            success: function (data)
            {
                if (data == '[]')
                {
                    alert('Please add some categories first!');
                    $('#btnCategory').click();
                }
                else
                {
                    var result = eval('(' + data + ')');
                    for (var i = 0; i < result.length; i++)
                    {
                        var s = "<option value='" + result[i].key + "'>" + result[i].name + "</option>";
                        $('#selectCategory').append(s);
                    }

                    $('#idAddIncome').focus();
                }
            }
        });

        $('#dt').calendar({
            onSelect: function (date)
            {
                SelectedDate = (date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate());
            }
        });

        $('#btnSaveIncome').click(function ()
        {
            var record = $('#selectCategory').val() + '|' + $('#idAddIncome').val() + '|' + SelectedDate + '|' + $('#idIncomeNotes').val() + '|1';
            $.ajax({
                type: "POST",
                url: "General.ashx",
                data: "mode=" + CurrentStep + "&record=" + record,
                async: false,
                success: function (data)
                {
                    CallBackAction(CurrentStep, 'Add');
                    //$('#btnIncome').click();
                }
            });
        });
    });
</script>
</html>
